﻿using System;
using System.Collections.Generic;
using System.Reflection;

using System.Linq;
using System.Text;
using System.Xml;
using DependencyLocate.Abstract;
namespace DependencyService.Imp
{
    public static class ReflectionFactory
    {
        private static string _windowType;
        private static string _buttonType;         
        static ReflectionFactory()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load("E:\\MyStudyProject\\Delegate\\Dependency\\Config\\Config.xml");
            XmlNode xmlNode = xmlDoc.ChildNodes[1];//config节点 ElementName="config"
            _buttonType = xmlNode.ChildNodes[1].ChildNodes[0].Value;
            _windowType = xmlNode.ChildNodes[0].ChildNodes[0].Value;
            
        }

        public static IWindown MakeWindow()
        {
            string assemblyName = Assembly.GetExecutingAssembly().FullName;//.GetName().Name;
            return Assembly.Load(assemblyName).CreateInstance(_windowType) as IWindown;
            
        }
        public static IButton MakeButton()
        {
            string assemblyName = Assembly.GetExecutingAssembly().FullName;//.GetName().Name;
            return Assembly.Load(assemblyName).CreateInstance(_buttonType) as IButton;
        }
    }
}
